﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Billing
{
    public class FontConverter
    {
        public FontConverter(bool FromUnicode)
        {
            if (FromUnicode)
            {
                fontFrom = "აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ";
                fontTo = "ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖ×ØÙÚÛÜÝÞßàáãä";
            }
            else
            {
                fontFrom = "ÀÁÂÃÄÅÆÈÉÊËÌÍÏÐÑÒÓÔÖ×ØÙÚÛÜÝÞßàáãä";
                fontTo = "აბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ";
            }
        }
        private string fontFrom;//= Properties.Settings.Default.fontArial;
        public string FontFrom
        {
            get { return fontFrom; }
            set { fontFrom = value; }
        }

        private string fontTo;//= Properties.Settings.Default.fontUnicode;
        public string FontTo
        {
            get { return fontTo; }
            set { fontTo = value; }
        }

        public string Convert(string strIn)
        {
            string strOut = string.Empty;

            for (int i = 0; i < strIn.ToCharArray().Length; i++)
            {
                if (FontFrom.IndexOf(strIn.ToCharArray()[i]) == -1)
                {
                    strOut += strIn.ToCharArray()[i].ToString();
                    continue;
                }
                int chrIndex = FontFrom.IndexOf(strIn.ToCharArray()[i]);
                strOut += FontTo[chrIndex].ToString();
            }
            return strOut;
        }
    }
}
